package com.vonchange.headb.utils.uuid;

import java.util.UUID;

import com.fasterxml.uuid.EthernetAddress;
import com.fasterxml.uuid.Generators;
import com.fasterxml.uuid.impl.TimeBasedGenerator;

public class UUIDUtil {
	private static String digits(long val, int digits) {
		long hi = 1L << (digits * 4);
		return NumberToStr.toString(hi | (val & (hi - 1)), 36)
				.substring(1);
	}
	static TimeBasedGenerator gen = Generators.timeBasedGenerator(EthernetAddress.fromInterface());
	public static String gen(){
		UUID uuid = gen.generate();		
		StringBuilder sb = new StringBuilder();
		String a1=digits(uuid.getMostSignificantBits() >> 32, 8);
		String a2=digits(uuid.getMostSignificantBits() >> 16, 4);
		String a3=digits(uuid.getMostSignificantBits(), 4);
		String a4=digits(uuid.getLeastSignificantBits() >> 48, 4);
		String a5=digits(uuid.getLeastSignificantBits(), 12);
		sb.append(a3).append(a2).append(a1).append(a5).append(a4);
		return sb.toString();
	}
     public static void main(String[] args) {
	    String string=	UUIDUtil.gen();
	    System.out.println(string);
	    System.out.println(UUIDUtil.gen());
	}
}
